home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / bigfig.trm < prev    next >
Text File  |  1993-09-15  |  4KB  |  124 lines

  1. /*
  2.  * $Id: bigfig.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  3.  */
  4.  
  5. /* GNUPLOT - fig.trm */
  6. /*
  7.  * Copyright (C) 1990, 1991, 1992
  8.  *
  9.  * Permission to use, copy, and distribute this software and its
  10.  * documentation for any purpose with or without fee is hereby granted,
  11.  * provided that the above copyright notice appear in all copies and
  12.  * that both that copyright notice and this permission notice appear
  13.  * in supporting documentation.
  14.  *
  15.  * Permission to modify the software is granted, but not the right to
  16.  * distribute the modified code.  Modifications are to be distributed
  17.  * as patches to released version.
  18.  *
  19.  * This software  is provided "as is" without express or implied warranty.
  20.  *
  21.  * This file is included by ../term.c.
  22.  *
  23.  * This terminal driver supports:
  24.  *  Fig graphics language
  25.  *
  26.  * AUTHORS
  27.  *  Micah Beck, David Kotz
  28.  *
  29.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  30.  *
  31.  */
  32.  
  33. /*
  34.  * Original for Fig code output by Micah Beck, 1989
  35.  * Department of Computer Science, Cornell University
  36.  * Updated by David Kotz for gnuplot 2.0
  37.  * More efficient output by Ian Dall
  38.  * Increased size of plot by Ian Dall
  39.  * Updated to FIG 2.1 (with color) by Vivek Khera
  40.  */
  41.  
  42. #define BFIG_HTIC       (7*FIG_RES/80)
  43. #define BFIG_VTIC       (7*FIG_RES/80)
  44. #define BFIG_FONT_S     (16)    /* size in points */
  45. #define BFIG_VCHAR      (BFIG_FONT_S*72/FIG_RES) /* height in pixels of font */
  46. #define BFIG_HCHAR      (BFIG_VCHAR*6/10) /* this is a guess at the width */
  47.  
  48. #define BFIG_ARROW_WIDTH (BFIG_HTIC/2 + 1)
  49. #define BFIG_ARROW_HEIGHT BFIG_HTIC
  50.  
  51.  
  52.  
  53. /* 8 inches wide by 5 inches high */
  54. #define BFIG_XMAX (8 * FIG_RES)
  55. #define BFIG_YMAX (5 * FIG_RES)
  56.  
  57. #define BFIG_XOFF (FIG_RES/2)
  58. #define BFIG_YOFF (FIG_RES/2)
  59.  
  60.  
  61. BFIG_vector(ux,uy)
  62.      unsigned int ux,uy;
  63. {
  64.   int x=ux, y=uy;
  65.  
  66.   if (FIG_polyvec_stat != FIG_poly_part)
  67.     {
  68.       fprintf(outfile, "%d %d %d %d %d %d %d %d %6.3f %d %d %d\n",
  69.               O_POLYLINE, T_POLYLINE,
  70.               FIG_type, 1, FIG_color, 0, FIG_DEFAULT, 0, FIG_spacing, 0,0,0);
  71.       fprintf(outfile, "%d %d",
  72.               BFIG_XOFF + FIG_posx, BFIG_YMAX + BFIG_YOFF - FIG_posy);
  73.       FIG_poly_vec_cnt = 1;
  74.       FIG_polyvec_stat = FIG_poly_part;
  75.     }
  76.   fprintf(outfile, " %d %d",
  77.           BFIG_XOFF +  x, BFIG_YMAX + BFIG_YOFF-y);
  78.   FIG_poly_vec_cnt++;
  79.   if (FIG_poly_vec_cnt > 50)
  80.     FIG_poly_clean(FIG_polyvec_stat);
  81.  
  82.   FIG_posx = x;
  83.   FIG_posy = y;
  84. }
  85.  
  86.  
  87. BFIG_arrow(sx, sy, ex, ey, head)
  88.         int sx, sy;     /* start coord */
  89.         int ex, ey;     /* end coord */
  90.     TBOOLEAN head;
  91. {
  92.     FIG_poly_clean(FIG_polyvec_stat);
  93.         fprintf(outfile, "%d %d %d %d %d %d %d %d %6.3f %d  %d %d\n",
  94.                 O_POLYLINE, T_POLYLINE,
  95.                 FIG_type, 1, FIG_color, 0, FIG_DEFAULT, 0, FIG_spacing,
  96.         0, head ? 1 : 0, 0);
  97.         /* arrow line */
  98.     if ( head )
  99.             fprintf(outfile, "%d %d %.3f %.3f %.3f\n",
  100.                     0, 0, 1.0,
  101.             (double)BFIG_ARROW_WIDTH, (double)BFIG_ARROW_HEIGHT);
  102.         fprintf(outfile, "%d %d %d %d 9999 9999\n",
  103.                 BFIG_XOFF + sx, BFIG_YOFF + BFIG_YMAX - sy,
  104.         BFIG_XOFF + ex, BFIG_YOFF + BFIG_YMAX - ey);
  105.  
  106.         FIG_posx = ex;
  107.         FIG_posy = ey;
  108. }
  109.  
  110. BFIG_put_text(x, y, str)
  111.         int x, y;
  112.         char *str;
  113. {
  114.   if (strlen(str) == 0) return;
  115.   FIG_poly_clean(FIG_polyvec_stat);
  116.   y -= FIG_VCHAR/2;    /* assuming vertical center justified */
  117.  
  118.     fprintf(outfile, "%d %d %d %d %d %d %d %6.3f %d %d %d %d %d %s\01\n",
  119.                   O_TEXT, FIG_justify,
  120.                   FIG_ROMAN_FONT, BFIG_FONT_S, FIG_DEFAULT, FIG_DEFAULT, 0,
  121.           FIG_angle, SPECIAL_TEXT, BFIG_VCHAR, BFIG_HCHAR*strlen(str),
  122.           BFIG_XOFF + x, BFIG_YMAX + BFIG_YOFF-y, str);
  123. }
  124.